<?php $this->_extends('_layouts/share_layout')?>

<?php $this->_block('title'); ?>
Share with Facebook Friends - LaLaLoot
<?php $this->_endblock(); ?>

<?php $this->_block('keywords');?>
<meta name="keywords" content="<?php echo $site['keywords']; ?>" />
<?php $this->_endblock();?>

<?php $this->_block('description');?>
<meta name="description" content="LaLaLoot: Share with Facebook Friends." />
<?php $this->_endblock();?>

<?php $this->_block('content'); ?>
<script src="<?php echo $js_url; ?>jquery.fb.multifriend.select.js" type="text/javascript" ></script>
<link href="<?php echo $css_url; ?>jquery.fb.multifriend.select-list.css" rel="stylesheet" type="text/css" />

<div class="white" style="width:600px; text-align:center; ">
	<div class="title">Share with Facebook Friends</div>
	<div id="shareToFacebook" style="display: none;"></div>
	<div style="width: 395px; margin:auto;">
		<div class="tr">
			<p id="message" class="sharetext">share with your friends on facebook! You will be rewarded five free token for each friend you invited and joined our game.</p>
		</div>
		<div class="tr" style="text-align:center;">
			<div id="fb-root"></div>
				<fb:login-button autologoutlink="true" perms="email,publish_stream"></fb:login-button>
				<?php if(isset($fbuid)): ?>
	      			<a href="#" id="directlygetfriends">Get Freinds</a>
	      			<script>
	      				$('#directlygetfriends').click(function(){
	      					getFriends('<?php echo $fb_js_token; ?>');
		      			});
	      			</script>
	      		<?php endif; ?>
	      	
	      	<script>
				FB.init({ 
		            appId: '<?php echo $fbsocials['appId']; ?>',
		            secret: '<?php echo $fbsocials['secret']; ?>', 
		            cookie:true, 
		            status:true, 
		            xfbml:true 
	         	});
				FB.Event.subscribe('auth.login', function(response) {
					parent.getFriends(response.session.access_token);
				});

				function getFriends(js_token){
					$('#formError').html('');
					$.ajax({
						 type: 'POST',
						 url: '<?php echo url('user/getfriends'); ?>',
						 data: {js_token: js_token},
						 success: function(data){
									$('#shareToFacebook').attr("style", "position:absolute;left:40%;top:15%;background:#CCFFAA");
									$('#shareToFacebook').html(data);
									$('#shareToFacebook').show();
					 			  },
					 	 dataType: 'html'
					});
				}
	      	</script>
		</div>
		<div class="tr">
			<a class="btn-3" style="margin:auto;" href="<?php echo url('user/step3'); ?>">Next</a>
		</div>
	</div>
</div>
<?php $this->_endblock(); ?>